package com.blb.thread;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * 自定义线程类
 */
public class MyRunnable implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + "--->" + i);
        }
    }

    public static void main(String[] args) {
        //创建Thread对象，构造方法中传入Runnable对象
        Thread thread = new Thread(new MyRunnable());
        //启动线程
        thread.start();

        //用lambda表达式实现线程
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName() + "--->" + i);
            }
        });
        thread1.start();

        List<Integer> numbers = Arrays.asList(33,22,66,44,99);
        // Comparator
        numbers.stream().sorted((n1,n2) -> n1 - n2).forEach(System.out::println);
    }
}
